/*
 * @(#)Shape.java        0.1 09/04/29
 * @version 	0.1 29 Apr 2009
 * @author 	Nguyen Thang Huy
 * 
 * Luu tru thong tin ve toa do, kich thuoc cua mot ClassFrame, doc du lieu tu XML
 */


package Data;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

import XML_IO.XML_IO;

public class Shape {
	int x, y, width, height;
	
	public Shape() {
		x = y = width = height = 0;
	}
	
	/*
	 * Doc toa do, kich tuoc 1 ClassFrame tu XML
	 */
	public Shape (Node node) {
		this();
		NamedNodeMap attributes = node.getAttributes();
		for (int k=0; k<attributes.getLength(); k++)
    	{
    		Node attribute = attributes.item(k);
    		if (attribute.getNodeName().equals("x")) {
    			x = Integer.parseInt(XML_IO.getElementValue(attribute));
    		} else if (attribute.getNodeName().equals("y")) {
    			y = Integer.parseInt(XML_IO.getElementValue(attribute));
    		} if (attribute.getNodeName().equals("width")) {
    			width = Integer.parseInt(XML_IO.getElementValue(attribute));
    		} else if (attribute.getNodeName().equals("height")) {
    			height = Integer.parseInt(XML_IO.getElementValue(attribute));
    		}
    	}
	}
	
	public int getX() {
		return x;
	}
	
	public void setX(int _x) {
		x = _x;
	}
	
	public int getY() {
		return y;
	}
	
	public void setY(int _y) {
		y = _y;
	}
	
	public int getWidth() {
		return width;
	}
	
	public void setWidth(int w) {
		width = w;
	}
	
	public int getHeight() {
		return height;
	}
	
	public void setHeight(int h) {
		height = h;
	}
}
